﻿Imports System
Imports System.Globalization
Imports System.Resources

Namespace System.Workflow.ComponentModel.Compiler
    Friend Class TypeSystemSR
        ' Methods
        Friend Sub New()
        End Sub

        Private Shared Function GetLoader() As TypeSystemSR
            If (TypeSystemSR.loader Is Nothing) Then
                TypeSystemSR.loader = New TypeSystemSR
            End If
            Return TypeSystemSR.loader
        End Function

        Friend Shared Function GetString(ByVal name As String) As String
            Return TypeSystemSR.GetString(TypeSystemSR.Culture, name)
        End Function

        Friend Shared Function GetString(ByVal culture As CultureInfo, ByVal name As String) As String
            Dim loader As TypeSystemSR = TypeSystemSR.GetLoader
            If (loader Is Nothing) Then
                Return Nothing
            End If
            Return loader.resources.GetString(name, culture)
        End Function

        Friend Shared Function GetString(ByVal name As String, ByVal ParamArray args As Object()) As String
            Return TypeSystemSR.GetString(TypeSystemSR.Culture, name, args)
        End Function

        Friend Shared Function GetString(ByVal culture As CultureInfo, ByVal name As String, ByVal ParamArray args As Object()) As String
            Dim loader As TypeSystemSR = TypeSystemSR.GetLoader
            If (loader Is Nothing) Then
                Return Nothing
            End If
            Dim format As String = loader.resources.GetString(name, culture)
            If ((Not args Is Nothing) AndAlso (args.Length > 0)) Then
                Return String.Format(CultureInfo.CurrentCulture, format, args)
            End If
            Return format
        End Function


        ' Properties
        Private Shared ReadOnly Property Culture As CultureInfo
            Get
                Return Nothing
            End Get
        End Property


        ' Fields
        Private Shared loader As TypeSystemSR
        Private resources As ResourceManager = New ResourceManager("System.Workflow.ComponentModel.Compiler.StringResources", Assembly.GetExecutingAssembly)
    End Class
End Namespace

